/**
 * Created with IntelliJ IDEA
 * Description:顺序表类
 * User:恋恋
 * Date:2022-10-18
 * Time:8:54
 */
class MyArray{
    public Object[] array=new Object[10];
    public Object getPos(int pos){
        return this.array[pos];
    }
    public void setVal(int pos,int val){
        this.array[pos]=val;
    }
}
public class TestDemo {
    public static void main(String[] args) {
        MyArray myArray=new MyArray();
        myArray.setVal(0,10);
        //编译错误
//        if(myArray.getPos(0) instanceof String){
//            String ret= myArray.getPos(0);
//        }
//        //ClassCastException类型转换异常，父类转子类存在风险
//        String ret2= (String) myArray.getPos(0);
//        System.out.println(ret);

    }
}
